<?php
namespace app\store\controller;
use think\Db;
use think\request;
use think\Controller;
class Order extends Controller
{
	protected function _initialize() {
		header('Access-Control-Allow-Origin:*');
	}
		   /* 
	 * 获取订单
	 */
	public function orders(){
		$where['a.status']=["neq",8];
		$where['a.type']=4;
		$where['a.add_time']=[">=",'2018-3-14'];
		$where['a.agent_id'] = session("agent_id");
		$status=0;
		if(input("status")){//订单状态
			$status=input("status");
			$where['a.status']=input("status");
		}
		$this->assign("status",$status);
		
		//获取线上订单信息
		$order_list = db('agent_syorder')
						->alias('a')
						->field('a.*,b.thumb,b.goods_name,b.sale_price,c.goods_num')
						->join('agent_goods b','b.id = a.goods_id','LEFT')
						->join('log_paylog c','c.order_sn = a.sn','LEFT')
						->where($where)
						->select();
		
		
		$this->assign("order_list",$order_list);
		return $this->fetch();
	}
}
